package testcase.command;

import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.NoSuchElementException;

import org.junit.Test;

import satir.card.Choice;
import satir.card.Question;
import satir.command.AskQuestionCmd;
import satir.player.Player;
import junit.framework.TestCase;


public class In_AskQuestionCmd_Choice_2 extends TestCase{
	/*
	 * Test step:1
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice one from event card one 
	 */
	@Test
		public void testQuestion1Choice1(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Mother notices her children talk with classmate at night about 30 mins or more. As Father, what is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("Blame him/her and prohibit use the phone more than 5 mins.", 1,new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Threaten son/daughter. If the situation still not change, you will modify the amount of pocket money.", -1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ignore him/her.", -1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);
		
		String input = "1";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(6,result);
		}
	/*
	 * Test step:2
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice two from event card one 
	 */
	@Test
		public void testQuestion1Choice2(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Mother notices her children talk with classmate at night about 30 mins or more. As Father, what is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("Blame him/her and prohibit use the phone more than 5 mins.", 1,new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Threaten son/daughter. If the situation still not change, you will modify the amount of pocket money.", -1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ignore him/her.", -1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);
		
		String input = "2";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(6,result);
		}
	
	/*
	 * Test step:3
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice three from event card one 
	 */
	@Test
		public void testQuestion1Choice3(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Mother notices her children talk with classmate at night about 30 mins or more. As Father, what is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("Blame him/her and prohibit use the phone more than 5 mins.", 1,new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Threaten son/daughter. If the situation still not change, you will modify the amount of pocket money.", -1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ignore him/her.", -1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);
		
		String input = "3";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(4,result);
		}
	
	/*
	 * Test step:4
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice four from event card one 
	 */
	@Test
		public void testQuestion1Choice4(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Mother notices her children talk with classmate at night about 30 mins or more. As Father, what is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("Blame him/her and prohibit use the phone more than 5 mins.", 1,new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Threaten son/daughter. If the situation still not change, you will modify the amount of pocket money.", -1, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ignore him/her.", -1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);
		
		String input = "4";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(4,result);
		}
	
	/*
	 * Test step:5
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice one from event card two 
	 */
	@Test
		public void testQuestion2Choice1(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Your children is facing the examination, Father prohibits his/her go outside since his/her Chinese subject result is only got 60 marks\nBut he/she is invited to attend the brithday party on this Saturday. As childern, What is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("You decide to go and lie to parent.", -2, new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("You will discuss with parent about the revision time.", 5, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ask bother or sister to give advice.", 1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);

		String input = "1";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(3,result);
	}

	/*
	 * Test step:6
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice two from event card two 
	 */
	@Test
		public void testQuestion2Choice2(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Your children is facing the examination, Father prohibits his/her go outside since his/her Chinese subject result is only got 60 marks\nBut he/she is invited to attend the brithday party on this Saturday. As childern, What is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("You decide to go and lie to parent.", -2, new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("You will discuss with parent about the revision time.", 5, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ask bother or sister to give advice.", 1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);

		String input = "2";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(6,result);
	}
	
	/*
	 * Test step:7
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice three from event card two 
	 */
	@Test
		public void testQuestion2Choice3(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Your children is facing the examination, Father prohibits his/her go outside since his/her Chinese subject result is only got 60 marks\nBut he/she is invited to attend the brithday party on this Saturday. As childern, What is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("You decide to go and lie to parent.", -2, new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("You will discuss with parent about the revision time.", 5, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ask bother or sister to give advice.", 1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);

		String input = "3";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(10,result);
	}	
	
	/*
	 * Test step:8
	 * Objective: Test integration of AskQuestionCmd and Choice, to get the self-Esteem Value of choice four from event card twp 
	 */
	@Test
		public void testQuestion2Choice4(){ 
		class QuestionStub extends Question{
			
			public QuestionStub() {
				super (null, null);
			}
			private ArrayList<Choice> choices;
			@Override
			public String getQuestion(){
				return "Your children is facing the examination, Father prohibits his/her go outside since his/her Chinese subject result is only got 60 marks\nBut he/she is invited to attend the brithday party on this Saturday. As childern, What is your decision?";
			}
			
			@Override
			public ArrayList<Choice> getChoices() {
				choices = new ArrayList<Choice>();
				choices.add(new Choice("You decide to go and lie to parent.", -2, new Hashtable<String, Integer>()));
				choices.add(new Choice("Talk with son/daughter and find the reason.", 1, new Hashtable<String, Integer>()));
				choices.add(new Choice("You will discuss with parent about the revision time.", 5, new Hashtable<String, Integer>()));
				choices.add(new Choice("Ask bother or sister to give advice.", 1, new Hashtable<String, Integer>()));
				return choices;
			}
		};
		
		class PlayerStub extends Player{
			private int selfEsteem;
			public PlayerStub(){
				selfEsteem=5;
			}
			@Override
			public void increaseSelfEsteem(int increaseValue){
				selfEsteem+=increaseValue;
			}
			
			public int getValue (){
				return selfEsteem;
			}
		};
		
		PlayerStub playerStub = new PlayerStub();
		QuestionStub questionStub = new QuestionStub();
		AskQuestionCmd askQuestionCmd = new AskQuestionCmd(questionStub, playerStub);

		String input = "4";
		System.setIn(new ByteArrayInputStream(input.getBytes()));
		try {
			askQuestionCmd.execute();
		} catch (NoSuchElementException e) {
		}
		int result = playerStub.getValue();
		assertEquals(6,result);
	}
	
}
